package io.renren.modules.app.controller;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.app.entity.BsBorrinformEntity;
import io.renren.modules.app.service.BsBorrinformService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;




/**
 * 借阅信息表
 *
 * @author zwl
 * @email ${email}
 * @date 2024-01-02 14:08:32
 */
@RestController
@RequestMapping("bs_borrinform/bsborrinform")
public class BsBorrinformController {
    @Autowired
    private BsBorrinformService bsBorrinformService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("bs_borrinform:bsborrinform:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bsBorrinformService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("bs_borrinform:bsborrinform:info")
    public R info(@PathVariable("id") Integer id){
		BsBorrinformEntity bsBorrinform = bsBorrinformService.getById(id);

        return R.ok().put("bsBorrinform", bsBorrinform);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("bs_borrinform:bsborrinform:save")
    public R save(@RequestBody BsBorrinformEntity bsBorrinform){
        bsBorrinform.setCreateTime(new Date());
        bsBorrinform.setUpdateTime(new Date());
        bsBorrinformService.saveBsBorrinformEntity(bsBorrinform);
//		bsBorrinformService.save(bsBorrinform);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("bs_borrinform:bsborrinform:update")
    public R update(@RequestBody BsBorrinformEntity bsBorrinform){
        bsBorrinform.setUpdateTime(new Date());
        bsBorrinformService.updateBsBorrinformEntity(bsBorrinform);
//		bsBorrinformService.updateById(bsBorrinform);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("bs_borrinform:bsborrinform:delete")
    public R delete(@RequestBody Integer[] ids){
		bsBorrinformService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
